package com.example.xiaomi.controller;

import com.example.xiaomi.entity.contentsinfo;
import com.example.xiaomi.service.ContentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("contents")
@CrossOrigin  //允许跨域
public class ContentsController {
    @Autowired
    private ContentsService service;

    /**
     * http://localhost:8080/contents/list    输出帖子所有相关信息
     */
    @GetMapping("/list")
    public List<contentsinfo> getAllContents(){
        List<contentsinfo> infoList=service.findAllContents();
        return infoList;
    }
}
